package com.bcx.crm.spring_boot.ApplicationEvent;

import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * Created by ys on 2018/4/8.
 */
@Component
//实现ApplicationListener接口，并指定监听的事件类型
public class DemoListener implements ApplicationListener<DemoEvent> {
    //重写 onApplicationEvent 方法，对传递进来的指定的监听类型进行处理
    @Override
    public void onApplicationEvent(DemoEvent event) {
        String msg = event.getMsg();
        System.out.println("demoListener 接受到了 demoPublisher 发布的消息"+msg);
    }
}
